let form = layui.form
form.verify({
  len: [/^\S{6,12}$/, '长度必须6~12位且不能出现空格'],
  pas: function(val){
   if(val === $('input[name=oldPwd]').val()){
     return '新密码不能跟原密码相同'
   }
   },
   same: function(val){
    if(val !== $('input[name=newPwd]').val()){
      return '两次输入的密码不相同'
    }
   }
  }
 
)


$('form').on('submit',function(e){
e.preventDefault()
let data = $(this).serialize()
$.ajax({
  type:'POST',
  url:'/my/user/updatepwd',
 data:data,
   success: function(res){
    if (res.status === 0 ) {
      layer.msg(res.message)
      localStorage.removeItem('token');
      window.parent.location.href = '../index.html'
    }
   }
})
})